home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Text Processing / Pyramid / Pyramid.Pascal.Code < prev    next >
Text File  |  1994-05-16  |  1KB  |  65 lines

  1. program pyramid;
  2. {written by John Gray}
  3.  
  4.  
  5.     var
  6.         r: rect;
  7.         word, c: string[150];
  8.         x, y, z: integer;
  9.         Data: text;
  10.  
  11.     procedure crunch;
  12.         var
  13.             k: integer;
  14.             v: integer;
  15.     begin
  16.         y := 0;
  17.         z := length(word);
  18.         for k := 1 to z do
  19.             begin
  20.                 v := ord(word[k]);
  21.                 case v of
  22.                     0..47, 58..64, 91..96, 123..256: 
  23.                         v := 0;
  24.                 end;
  25.                 if (v >= 97) and (v <= 122) then
  26.                     v := v - 96;
  27.                 if (v >= 65) and (v <= 90) then
  28.                     v := v - 64;
  29.                 if (v >= 48) and (v <= 57) then
  30.                     v := v - 48;
  31.                 y := y + v;
  32.             end;
  33.     end;
  34.  
  35.     procedure displaystuff;
  36.     begin
  37.         writeln('Input text.  Enter "bye" to quit.');
  38.         writeln;
  39.         write('->');
  40.         readln(word);
  41.         crunch;
  42.         writeln('Total  : ', y);
  43.         writeln(data, word, y);
  44.         writeln(data);
  45.         writeln;
  46.         if word <> 'bye' then
  47.             displaystuff;
  48.     end;
  49.  
  50.  
  51. begin {main}
  52.     rewrite(Data, 'Data');
  53.     setrect(r, 20, 40, 500, 375);
  54.     settextrect(r);
  55.     showtext;
  56.     writeln('Pyramid, by John Gray.  Compiled in THINK Pascal.');
  57.     writeln;
  58.     writeln('Enormous thanks to THINK technologies for programming the compiler. ');
  59.     writeln('Read the "Readme" file if you hope to understand this program at all…');
  60.     writeln;
  61.     writeln;
  62.     displaystuff;
  63.     writeln(Data, '----------------------------------------------');
  64.     close(Data);
  65. end.